package com.huatai.exchange.connection;

import com.alibaba.druid.pool.DruidDataSource;
import com.faneui.common.exception.BusinessException;
import com.faneui.dal.DBUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.Connection;

@Component
public class LocalConnection {

    @Autowired
    private DruidDataSource dataSource;

    private Connection conn;

    public Connection getConn() throws BusinessException {
        if (conn == null) {
            conn = DBUtils.getConnection(dataSource);
        }
        return conn;
    }

}
